package com.kateba.android.utils;

import java.io.IOException;

import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.BasicResponseHandler;
import org.apache.http.impl.client.DefaultHttpClient;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;

public class Utils
{
  public static int MAX_TEXT_LEN = 100;
  final String LOG_TAG = "BlueInput::Agentii";

  // ERROR //
  public static String AssetTextFileToString(Context paramContext, String paramString)
  {
	return paramString;
    // Byte code:
    //   0: aconst_null
    //   1: astore_2
    //   2: aconst_null
    //   3: astore_3
    //   4: new 25	java/io/BufferedReader
    //   7: dup
    //   8: new 27	java/io/InputStreamReader
    //   11: dup
    //   12: aload_0
    //   13: invokevirtual 33	android/content/Context:getAssets	()Landroid/content/res/AssetManager;
    //   16: aload_1
    //   17: invokevirtual 39	android/content/res/AssetManager:open	(Ljava/lang/String;)Ljava/io/InputStream;
    //   20: invokespecial 42	java/io/InputStreamReader:<init>	(Ljava/io/InputStream;)V
    //   23: invokespecial 45	java/io/BufferedReader:<init>	(Ljava/io/Reader;)V
    //   26: astore 4
    //   28: aload 4
    //   30: invokevirtual 49	java/io/BufferedReader:readLine	()Ljava/lang/String;
    //   33: astore 9
    //   35: aload 9
    //   37: ifnonnull +10 -> 47
    //   40: aload 4
    //   42: invokevirtual 52	java/io/BufferedReader:close	()V
    //   45: aload_2
    //   46: areturn
    //   47: aload_2
    //   48: ifnonnull +6 -> 54
    //   51: ldc 54
    //   53: astore_2
    //   54: new 56	java/lang/StringBuilder
    //   57: dup
    //   58: aload_2
    //   59: invokestatic 62	java/lang/String:valueOf	(Ljava/lang/Object;)Ljava/lang/String;
    //   62: invokespecial 65	java/lang/StringBuilder:<init>	(Ljava/lang/String;)V
    //   65: aload 9
    //   67: invokevirtual 69	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   70: invokevirtual 72	java/lang/StringBuilder:toString	()Ljava/lang/String;
    //   73: astore_2
    //   74: new 56	java/lang/StringBuilder
    //   77: dup
    //   78: aload_2
    //   79: invokestatic 62	java/lang/String:valueOf	(Ljava/lang/Object;)Ljava/lang/String;
    //   82: invokespecial 65	java/lang/StringBuilder:<init>	(Ljava/lang/String;)V
    //   85: ldc 74
    //   87: invokevirtual 69	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   90: invokevirtual 72	java/lang/StringBuilder:toString	()Ljava/lang/String;
    //   93: astore 10
    //   95: aload 10
    //   97: astore_2
    //   98: goto -70 -> 28
    //   101: astore 5
    //   103: aload 5
    //   105: invokevirtual 77	java/io/IOException:printStackTrace	()V
    //   108: aload_3
    //   109: invokevirtual 52	java/io/BufferedReader:close	()V
    //   112: goto -67 -> 45
    //   115: astore 8
    //   117: aload 8
    //   119: invokevirtual 77	java/io/IOException:printStackTrace	()V
    //   122: goto -77 -> 45
    //   125: astore 6
    //   127: aload_3
    //   128: invokevirtual 52	java/io/BufferedReader:close	()V
    //   131: aload 6
    //   133: athrow
    //   134: astore 7
    //   136: aload 7
    //   138: invokevirtual 77	java/io/IOException:printStackTrace	()V
    //   141: goto -10 -> 131
    //   144: astore 11
    //   146: aload 11
    //   148: invokevirtual 77	java/io/IOException:printStackTrace	()V
    //   151: goto -106 -> 45
    //   154: astore 6
    //   156: aload 4
    //   158: astore_3
    //   159: goto -32 -> 127
    //   162: astore 5
    //   164: aload 4
    //   166: astore_3
    //   167: goto -64 -> 103
    //
    // Exception table:
    //   from	to	target	type
    //   4	28	101	java/io/IOException
    //   108	112	115	java/io/IOException
    //   4	28	125	finally
    //   103	108	125	finally
    //   127	131	134	java/io/IOException
    //   40	45	144	java/io/IOException
    //   28	35	154	finally
    //   51	95	154	finally
    //   28	35	162	java/io/IOException
    //   51	95	162	java/io/IOException
  }

  public static void CallNumber(Context paramContext, String paramString)
  {
    paramContext.startActivity(new Intent("android.intent.action.CALL", Uri.parse("tel:" + paramString)));
  }

  public static String DownloadStringFromWeb(String paramString)
  {
    String str = null;
    DefaultHttpClient localDefaultHttpClient = new DefaultHttpClient();
    try
    {
      str = (String)localDefaultHttpClient.execute(new HttpGet(paramString), new BasicResponseHandler());
      return str;
    }
    catch (ClientProtocolException localClientProtocolException)
    {
      while (true)
      {
        localClientProtocolException.printStackTrace();
        localDefaultHttpClient.getConnectionManager().shutdown();
      }
    }
    catch (IOException localIOException)
    {
      while (true)
      {
        localIOException.printStackTrace();
        localDefaultHttpClient.getConnectionManager().shutdown();
      }
    }
    finally
    {
      localDefaultHttpClient.getConnectionManager().shutdown();
    }
  //  throw localObject;
  }

  public static void OpenWeb(Context paramContext, String paramString)
  {
    paramContext.startActivity(new Intent("android.intent.action.VIEW", Uri.parse(paramString)));
  }

  public static void SendEmail(Context paramContext, String[] paramArrayOfString, String paramString1, String paramString2)
  {
    Intent localIntent = new Intent("android.intent.action.SEND");
    localIntent.setType("plain/text");
    localIntent.putExtra("android.intent.extra.SUBJECT", paramString1);
    localIntent.putExtra("android.intent.extra.TEXT", paramString2);
    localIntent.putExtra("android.intent.extra.EMAIL", paramArrayOfString);
    paramContext.startActivity(Intent.createChooser(localIntent, ""));
  }

  public static String ShortText(String paramString)
  {
    if ((paramString != null) && (paramString.length() > MAX_TEXT_LEN))
      paramString = paramString.substring(0, MAX_TEXT_LEN) + "..";
    return paramString;
  }

  public static void StartActivity(Context paramContext, Class paramClass)
  {
    paramContext.startActivity(new Intent(paramContext, paramClass));
  }

  public static void StartActivity(Context paramContext, Class paramClass, Bundle paramBundle)
  {
    Intent localIntent = new Intent(paramContext, paramClass);
    if (paramBundle != null)
      localIntent.putExtras(paramBundle);
    paramContext.startActivity(localIntent);
  }
}